// Created from GroupGenerationTemplate
// For Decisions HL7 Engine
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.Serialization;
using DecisionsFramework.Design.Properties;
using Decisions.HL7.DataTypes;
using ST = System.String;
using SI = System.String;
using IS = System.String;
using ID = System.String;
using SNM = System.String;

namespace Decisions.HL7.Message
{
    [DataContract]
	public class COMMON_ORDER_RSP_Z86 : AbstractGroup
    {
        /// -----------------------------
        /// -----------------------------
		[DataMember]
	    [PropertyClassification("25 ORC",25)]
  	    [HL7Field(HL7Version.v24, 25, HL7Repeat.False, HL7Required.True,"ORC")]
	    public ORC ORC {get;set;}

        /// -----------------------------
        /// -----------------------------
		[DataMember]
	    [PropertyClassification("26 ORDER_DETAIL",26)]
  	    [HL7Field(HL7Version.v24, 26, HL7Repeat.False, HL7Required.False,"ORDER_DETAIL_RSP_Z86")]
	    public ORDER_DETAIL_RSP_Z86 ORDER_DETAIL {get;set;}

        /// -----------------------------
        /// -----------------------------
		[DataMember]
	    [PropertyClassification("37 ENCODED_ORDER",37)]
  	    [HL7Field(HL7Version.v24, 37, HL7Repeat.False, HL7Required.False,"ENCODED_ORDER_RSP_Z86")]
	    public ENCODED_ORDER_RSP_Z86 ENCODED_ORDER {get;set;}

        /// -----------------------------
        /// -----------------------------
		[DataMember]
	    [PropertyClassification("48 DISPENSE",48)]
  	    [HL7Field(HL7Version.v24, 48, HL7Repeat.False, HL7Required.False,"DISPENSE_RSP_Z86")]
	    public DISPENSE_RSP_Z86 DISPENSE {get;set;}

        /// -----------------------------
        /// -----------------------------
		[DataMember]
	    [PropertyClassification("59 GIVE",59)]
  	    [HL7Field(HL7Version.v24, 59, HL7Repeat.False, HL7Required.False,"GIVE_RSP_Z86")]
	    public GIVE_RSP_Z86 GIVE {get;set;}

        /// -----------------------------
        /// -----------------------------
		[DataMember]
	    [PropertyClassification("70 ADMINISTRATION",70)]
  	    [HL7Field(HL7Version.v24, 70, HL7Repeat.False, HL7Required.False,"ADMINISTRATION_RSP_Z86")]
	    public ADMINISTRATION_RSP_Z86 ADMINISTRATION {get;set;}

        /// -----------------------------
        /// -----------------------------
		[DataMember]
	    [PropertyClassification("81 OBSERVATION",81)]
  	    [HL7Field(HL7Version.v24, 81, HL7Repeat.True, HL7Required.True,"OBSERVATION_RSP_Z86")]
	    public OBSERVATION_RSP_Z86[] OBSERVATION {get;set;}



		#region Parser Helpers and Conrete Impls

        internal override void ConsumeTextSegmentsForGroup(Stack<string> availableData, HL7ParserOptions options) {

			ORC = PopSegmentParseAndCheckRequired<ORC>(availableData, options, "ORC");
			ORDER_DETAIL = ProcessGroup<ORDER_DETAIL_RSP_Z86>(availableData, options, "ORDER_DETAIL");
			ENCODED_ORDER = ProcessGroup<ENCODED_ORDER_RSP_Z86>(availableData, options, "ENCODED_ORDER");
			DISPENSE = ProcessGroup<DISPENSE_RSP_Z86>(availableData, options, "DISPENSE");
			GIVE = ProcessGroup<GIVE_RSP_Z86>(availableData, options, "GIVE");
			ADMINISTRATION = ProcessGroup<ADMINISTRATION_RSP_Z86>(availableData, options, "ADMINISTRATION");
			OBSERVATION = ProcessGroupArray<OBSERVATION_RSP_Z86>(availableData, options, "OBSERVATION");
        }

		internal override bool CanConsume(string availableData, HL7ParserOptions options)
        {
			bool isORC = availableData.StartsWith("ORC", StringComparison.OrdinalIgnoreCase);
			if (IsRequired("ORC", options.Version) || isORC) {
				return isORC;
			}
			ORDER_DETAIL_RSP_Z86 testORDER_DETAIL_RSP_Z86 = new ORDER_DETAIL_RSP_Z86();
			bool grpCCORDER_DETAIL_RSP_Z86 = (testORDER_DETAIL_RSP_Z86.CanConsume(availableData, options));
			if (IsRequired("ORDER_DETAIL", options.Version) || grpCCORDER_DETAIL_RSP_Z86) {
				return grpCCORDER_DETAIL_RSP_Z86;
			}
			ENCODED_ORDER_RSP_Z86 testENCODED_ORDER_RSP_Z86 = new ENCODED_ORDER_RSP_Z86();
			bool grpCCENCODED_ORDER_RSP_Z86 = (testENCODED_ORDER_RSP_Z86.CanConsume(availableData, options));
			if (IsRequired("ENCODED_ORDER", options.Version) || grpCCENCODED_ORDER_RSP_Z86) {
				return grpCCENCODED_ORDER_RSP_Z86;
			}
			DISPENSE_RSP_Z86 testDISPENSE_RSP_Z86 = new DISPENSE_RSP_Z86();
			bool grpCCDISPENSE_RSP_Z86 = (testDISPENSE_RSP_Z86.CanConsume(availableData, options));
			if (IsRequired("DISPENSE", options.Version) || grpCCDISPENSE_RSP_Z86) {
				return grpCCDISPENSE_RSP_Z86;
			}
			GIVE_RSP_Z86 testGIVE_RSP_Z86 = new GIVE_RSP_Z86();
			bool grpCCGIVE_RSP_Z86 = (testGIVE_RSP_Z86.CanConsume(availableData, options));
			if (IsRequired("GIVE", options.Version) || grpCCGIVE_RSP_Z86) {
				return grpCCGIVE_RSP_Z86;
			}
			ADMINISTRATION_RSP_Z86 testADMINISTRATION_RSP_Z86 = new ADMINISTRATION_RSP_Z86();
			bool grpCCADMINISTRATION_RSP_Z86 = (testADMINISTRATION_RSP_Z86.CanConsume(availableData, options));
			if (IsRequired("ADMINISTRATION", options.Version) || grpCCADMINISTRATION_RSP_Z86) {
				return grpCCADMINISTRATION_RSP_Z86;
			}
			OBSERVATION_RSP_Z86 testOBSERVATION_RSP_Z86 = new OBSERVATION_RSP_Z86();
			bool grpCCOBSERVATION_RSP_Z86 = (testOBSERVATION_RSP_Z86.CanConsume(availableData, options));
			if (IsRequired("OBSERVATION", options.Version) || grpCCOBSERVATION_RSP_Z86) {
				return grpCCOBSERVATION_RSP_Z86;
			}
			return false;
        }

        private static Dictionary<string, bool> SEGMENT_VERSION_REQUIRED_MAP = new Dictionary<string, bool>();

		protected override Dictionary<string, bool> MAP_OF_SEGMENT_TO_REQUIRED
        {
            get
			{
				return SEGMENT_VERSION_REQUIRED_MAP;
			}
        }

		public override string HL7ENTITY_TYPE_NAME
        {
            get {
				return "COMMON_ORDER";
			}
        }

        static COMMON_ORDER_RSP_Z86() {

             SetupStaticPropertyMap(SEGMENT_VERSION_REQUIRED_MAP, typeof(COMMON_ORDER_RSP_Z86));

        }

		#endregion

		public override string GetER7(HL7ParserOptions options)
		{
			List<string> segmentData = new List<string>();
		 if (ORC != null) {
			string segmentValue = ORC.GetER7(options);
			if (string.IsNullOrEmpty(segmentValue) == false) {
				segmentData.Add(segmentValue);
			}
		 }
		 if (ORDER_DETAIL != null) {
			string segmentValue = ORDER_DETAIL.GetER7(options);
			if (string.IsNullOrEmpty(segmentValue) == false) {
				segmentData.Add(segmentValue);
			}
		 }
		 if (ENCODED_ORDER != null) {
			string segmentValue = ENCODED_ORDER.GetER7(options);
			if (string.IsNullOrEmpty(segmentValue) == false) {
				segmentData.Add(segmentValue);
			}
		 }
		 if (DISPENSE != null) {
			string segmentValue = DISPENSE.GetER7(options);
			if (string.IsNullOrEmpty(segmentValue) == false) {
				segmentData.Add(segmentValue);
			}
		 }
		 if (GIVE != null) {
			string segmentValue = GIVE.GetER7(options);
			if (string.IsNullOrEmpty(segmentValue) == false) {
				segmentData.Add(segmentValue);
			}
		 }
		 if (ADMINISTRATION != null) {
			string segmentValue = ADMINISTRATION.GetER7(options);
			if (string.IsNullOrEmpty(segmentValue) == false) {
				segmentData.Add(segmentValue);
			}
		 }
		 if (OBSERVATION != null && OBSERVATION.Length > 0) {
			for (int i = 0; i < OBSERVATION.Length; i++) {
				string segmentValue = OBSERVATION[i].GetER7(options);
				if (string.IsNullOrEmpty(segmentValue) == false) {
					segmentData.Add(segmentValue);
				}
			}
		 }
           return string.Join(HL7ParserConstants.SEGMENT_SEPARATOR, segmentData.ToArray());
        
        }
    }
}

